//
//  AccountCollectCell.m
//  ImGuider
//
//  Created by llt on 2017/6/7.
//  Copyright © 2017年 imguider. All rights reserved.
//

#import "AccountCollectCell.h"
#import "StarRateView.h"

@interface AccountCollectCell ()

@property (weak, nonatomic) IBOutlet UIImageView *guiderImageView;

@property (weak, nonatomic) IBOutlet UILabel *guiderNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *guiderApproveLabel;
@property (weak, nonatomic) IBOutlet UILabel *scenicCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *listenCountLabel;
@property (weak, nonatomic) IBOutlet UILabel *collectCountLabel;

@property (weak, nonatomic) IBOutlet StarRateView *starView;
@property (weak, nonatomic) IBOutlet UIImageView *vipTagImageView;

@property (weak, nonatomic) IBOutlet UIButton *collectBtn;

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *guiderNameCenter;

@end

@implementation AccountCollectCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.guiderImageView.layer.borderColor = kContentColor.CGColor;
    self.guiderImageView.layer.borderWidth = 1.0f;
    self.guiderApproveLabel.textColor = kThemeRedColor;
}


- (void)setGuider:(GuiderCardModel *)guider {
    
    _guider = guider;
    self.guiderNameLabel.text = guider.realname;
    self.scenicCountLabel.text = guider.viewcount;
    self.listenCountLabel.text = guider.visitcount;
    self.collectCountLabel.text = guider.favourcount;
    self.guiderApproveLabel.text = guider.certificate;
    
    
    if (guider.certificate.length > 0) {
        self.guiderNameCenter.constant = -10;
    } else {
        self.guiderNameCenter.constant = 0;
    }
    
    [self.starView setScore:guider.score.floatValue / 10.0];
    
    self.vipTagImageView.hidden = !guider.vip;
    
    [self.guiderImageView setImageURL:[NSURL URLWithString:guider.headimg] placeholderImage:[UIImage imageNamed:@"default"]];
    
    self.collectBtn.selected = guider.isfavor;
    
}
- (IBAction)collectBtnAction:(id)sender {
    
    if ([_delegate respondsToSelector:@selector(collect:guider:)]) {
        [_delegate collect:self guider:self.guider];
    }
}

@end
